package com.neusoft.neu24.nep.role.controller;

import com.neusoft.neu24.nep.entity.ComonResult;
import com.neusoft.neu24.nep.role.entity.Roles;
import com.neusoft.neu24.nep.role.service.IRolesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 角色表 前端控制器
 * </p>
 *
 * @author 段静迪，duanjingdi@163.com
 * @since 2024-06-05
 */
@RestController
@RequestMapping("/role")
@CrossOrigin("*")
public class RolesController {

    @Autowired
    IRolesService rolesService;


    @GetMapping("q/menu/{roleid}")

    public ComonResult  selectMenuByRoleid(@PathVariable("roleid")  Integer  roleid){
        return  rolesService.selectMenuByRoleid(roleid);
    }

    @PutMapping("auth/{rid}" )
    public ComonResult  modRoleAuth(@PathVariable("rid")  Integer  rid,@RequestBody  List<Integer>  sysnodeids){
        return  rolesService.modRoleAuth( rid,sysnodeids);
    }




    @GetMapping("select/sysnodes/{rid}")
/**
 * 所有的系统节点，不包括分支节点
 */
    public ComonResult  selectSysnodesByRid(@PathVariable("rid")  Integer  rid){

        return   rolesService.selectSysnodesByRid( rid);
    }


    @PutMapping("mod")
    public ComonResult  modRole(@RequestBody  Roles  roles){
        return   rolesService.modRole(   roles);
    }


    @PostMapping("new")
    public ComonResult addRole(@RequestBody  Roles  roles){
        return   rolesService.addRole( roles);
    }


    @GetMapping("s/list/all")
    public ComonResult<List<Roles>> listAll(){
        return rolesService.listAll();
    }

    @PutMapping("u/byid")
    public ComonResult  modRoleByid(@RequestBody  Roles  roles){
        return   rolesService.modRoleByid(   roles);
    }



}
